<?php
/* -----------------------------------------------------------------
 *                        Aveghe My Blog
 * -----------------------------------------------------------------
 * Aveghe My Blog: made your blog easy!
 * Copyright (C) 2008 Elia Contini
 * 
 * Aveghe My Blog is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * Aveghe My Blog is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301, USA.
 */

$baseURL = BASE_URL;

$meta    = $this->head('meta'   , 'public', $this->preferences);
$style   = $this->head('style'  , 'public', $this->preferences);
$favicon = $this->head('favicon', 'public', $this->preferences);
$rss     = $this->head('rss'    , 'public', $this->preferences);

$siteTitle = '<h1><a href="'.$baseURL.'/" title="">'.stripcslashes($this->preferences['site_title'])."</a></h1>\n";

$report = '';
$content = '';

if(count($this->posts) == 0)
	$content = 'Non sono presenti post';
else
	{
		foreach($this->posts as $post)
			{
				$content .= "\n\t<h2 class=\"postTitle\"><a href=\"".$baseURL."/post/view/id/".$post['document_id']."\" title=\"\">".stripcslashes($post['document_name'])."</a></h2>\n";
				$content .= "\t<div class=\"postText\">".stripcslashes($post['document_content'])."</div>\n";
				$content .= "\t<p class=\"tags\"><strong>Etichette</strong>: ".$post['document_keywords']."</p>\n";
				$content .= '<p class="postInfo">Scritto da '.$post['user_name'].' '.$post['user_surname'].' il '.$this->formatDateTime($post['document_creation_date']);
				//$content .= "\t<p class=\"postInfo\">Scritto da <a href=\"#".$posts['user_id']."\" title=\"\">".$posts['user_name']." ".$posts['user_surname']."</a> il ".$this->formatDateTime($posts['document_modification_date'])."</p>\n";
				// adSense
				//$postUrl = $this->preferences['site_domain'].'/post/view/id/'.$posts['document_id'];
				//$content .= '<script src="http://feeds.feedburner.com/~s/AvegheTestBlog?i='.$postUrl.'" type="text/javascript" charset="utf-8"></script>';
				if($this->preferences['site_comments'] != 'disable' && $post['document_comments_enable'] == 1)
					$content .= ' | <a href="'.$baseURL.'/post/view/id/'.$post['document_id'].'#comments" title="">'.$post['document_comments_counter']." commenti</a></p>\n";
				else
					$content .= "</p>\n";
			}
		$content .= "\n";
	}
	
// pages
if($this->pageNum > 1)
	{
		$content .= "\n\t<p id=\"pagesIndex\">";
		for($i = 0; $i < $this->pageNum; $i++)
			{
				if($i == $this->currentPage)
					$content .= "\n\t\t<strong>".($i + 1).'</strong>';
				else
					$content .= "\n\t\t<a href=\"".$baseURL.'/post/view-all/page/'.$i.'" title="Elenco post: pagina '.($i + 1).'">'.($i + 1).'</a>';
					
				if(($i + 1) < $this->pageNum)
					$content .= ' <span class="hidden">|</span> ';
			}
		$content .= "\n\t</p>\n";
	}

$categories = $this->categoriesList($this->categories, 0);

include 'aveghe/themes/public/'.$this->preferences['site_public_theme'].'/template_public.xhtml';
?>